<template>
  <div style="line-height: 1.8">
    <h3>练习题</h3>
    <div v-if="qType == 1" v-loading="qLoading">
      <div class="q-title" v-html="question.title" />
      <div v-if="question.expend?.length" class="q-content">
        <el-radio-group v-model="answer.result" @change="answer.completed = true">
          <el-radio v-for="(item, index) in question.expend" :key="index" :label="index">
            <span class="question-prefix">{{ index }}.</span>
            <span v-html="item" class="q-item-span-content"></span>
          </el-radio>
        </el-radio-group>
      </div>
      <div v-else>
        <el-input v-model="answer.result" type="textarea" rows="5" @change="answer.completed = true" />
      </div>
    </div>
    <div v-else-if="qType == 2" v-loading="qLoading">
      <div class="q-title" v-html="question.title" />
      <div>
        <el-input v-model="answer.result" type="textarea" rows="5" @change="answer.completed = true" />
      </div>
    </div>
    <div v-else-if="qType == 3" v-loading="qLoading">
      <div class="q-title" v-html="question.title" />
      <div>
        <el-input v-model="answer.result" type="textarea" rows="5" @change="answer.completed = true" />
      </div>
    </div>
    <div v-else></div>
  </div>

  <!-- 
          {
            id: 15,
            createUserId: null,
            knowledgeId: 6,
            type: 1,
            title: "1-1的结果是什么",
            index: null,
            defaultScore: 1153,
            difficulty: 10,
            expend: [],
          }, -->
</template>

<script>
export default {
  name: "QuestionShow",
  props: {
    question: {
      type: Object,
      default: function () {
        return {};
      },
    },
    answer: {
      type: Object,
      default: function () {
        return { id: null, result: "", completed: false };
        // {"problemId": 9,
        //     "title": "1/0可行吗",
        //     "type": 1,
        //     "difficulty": 4,
        //     "answer": "answer9",
        //     "explanation": "explanation9",
        //     "falliblePoint": "9",
        //     "chapter": "chapter9",
        //     "knowledgeId": 2,
        //     "knowledge": "2+2是否等于4",
        //     "result": "studentanswer"
        // },
      },
    },
    qLoading: {
      type: Boolean,
      default: false,
    },
    qType: {
      type: Number,
      default: 0,
    },
    index: {
      type: Number,
      default: 0,
    },
  },
  methods: {},
};
</script>
